import Vue from 'vue'

import 'normalize.css/normalize.css' // css样式初始化
import ElementUI from 'element-ui'// element组件
import 'element-ui/lib/theme-chalk/index.css'// element-ui样式
import locale from 'element-ui/lib/locale/lang/en' // element的英文包
import '@/styles/index.scss' // 全局样式文件
import App from './App'
import store from './store'
import router from './router'
import '@/icons' // svg图标
import '@/permission' // 权限控制(导航守卫)
import MyUI from '@/components'
Vue.use(MyUI)
// import { from } from 'core-js/core/array'
/**
 * If you don't want to use mock-server
 * you want to use MockJs for mock api
 * you can execute: mockXHR()
 *
 * Currently MockJs will be used in the production environment,
 * please remove it before going online ! ! !
 */
// if (process.env.NODE_ENV === 'production') {
//   const { mockXHR } = require('../mock')
//   mockXHR()
// }
// import { imgerr, red } from '@/directives'
// Vue.directive('imgerror', imgerr)
// Vue.directive('red', red)
// 批量注册指令
import * as allDirectives from '@/directives'
// console.log(allDirectives)
// 第一种 遍历对象，批量注册
// for (const k in allDirectives) {
//   Vue.directive(k, allDirectives[k])
// }
// 第二种 Objct.keys遍历
Object.keys(allDirectives).forEach(k => Vue.directive(k, allDirectives[k]))
// 使用elementui英文ban
Vue.use(ElementUI, { locale })
// 如果想要中文版 element-ui，按如下方式声明
// Vue.use(ElementUI)

Vue.config.productionTip = false

new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
})
